# -*- coding: utf-8 -*-
import os


def disk_usage(path:str):
    """计算一个文件夹占用的磁盘空间

    Return the number of bytes used by a file/folder and any descendents..
    :param path:
    :return:
    """
    total = os.path.getsize(path)
    if os.path.isdir(path):
        for filename in os.listdir(path):
            total += disk_usage(os.path.join(path,filename))
    print('{0:<7}'.format(total),path)
    return total

if __name__ == "__main__":
    disk_usage(os.path.dirname('D:\\PycharmProjects\\'))
